package com.atm.atmsys.Mapper.TransactionMapper;

import com.atm.atmsys.dto.TransactionPageByCardNo;
import com.atm.atmsys.dto.TransactionPageQueryDTO;
import com.atm.atmsys.entity.AdminInfo;
import com.atm.atmsys.entity.TransactionRecord;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface TransactionMapper {
    //增加交易记录
    void addTransaction(TransactionRecord transactionRecord);

    //取钱交易记录,不改变数据库
    @Insert("insert into atm_database.transaction_record (card_no1,card_no2,money,status,tran_time,atm_id)"
            + "values (#{cardNo1},#{cardNo2},#{money},#{status},#{tranTime},#{atmId})")
    void withdrawTransaction(TransactionRecord transactionRecord);

    //存钱交易记录,不改变数据库
    @Insert("insert into atm_database.transaction_record (card_no1,card_no2,money,status,tran_time,atm_id)"
            + "values (#{cardNo1},#{cardNo2},#{money},#{status},#{tranTime},#{atmId})")
    void saveTransaction(TransactionRecord transactionRecord);

    //转账交易记录,不改变数据库
    @Insert("insert into atm_database.transaction_record (card_no1,card_no2,money,status,tran_time,atm_id)"
            + "values (#{cardNo1},#{cardNo2},#{money},#{status},#{tranTime},#{atmId})")
    void transferTransaction(TransactionRecord transactionRecord);


    //删除交易记录
    @Delete("delete from atm_database.transaction_record where tran_id = #{id}")
    void deleteTransaction(int id);

    //分页查询交易记录
    Page<TransactionRecord> pageQuery(TransactionPageQueryDTO transactionPageQueryDTO);


    //根据卡号查询交易记录
    Page<TransactionRecord> pageByCardNo(TransactionPageByCardNo transactionPageByCardNo);


}
